package com.ybwh.springboot1.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ybwh.springboot1.dao.OrderDao;
import com.ybwh.springboot1.model.po.Order;

@Service
public class OrderService {
	@Autowired
	private OrderDao orderDao;

	@Transactional
	public void update(Order o) {
		Order o1 = orderDao.findById(Order.class, o.getOrderId());
		System.out.println("11111@@@@@@@@@" + o1.toString());
		orderDao.update(o);
		Order o2 = orderDao.findById(Order.class, o.getOrderId());
		System.out.println("22222@@@@@@@@@" + o2.toString());
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				Order o3 = orderDao.findById(Order.class, o.getOrderId());
				System.out.println("33333@@@@@@@@@" + o3.toString());
				
			}
		}).start();
		
		
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
		}
	}

}
